export default function bwPowerSet(originalSet: any[]) {
  const subSets = []
  const numberOfCombination = 2 ** originalSet.length
  for (
    let combinationIndex = 0;
    combinationIndex < numberOfCombination;
    combinationIndex++
  ) {
    const subSet = []
    for(
      let setElementIndex = 0;
      setElementIndex < originalSet.length;
      setElementIndex++
    ) {
      // '&'：位与运算符，二进制逐位比较，同者为true
      // '<<'：左移运算符，二进制左移对应位数，高位移出，低位补零
      if (combinationIndex & (1 << setElementIndex)) {
        subSet.push(originalSet[setElementIndex])
      }
    }
    subSets.push(subSet)
  }
  return subSets
}